package com.ckerchina.admin.ckadmin.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ckerchina.admin.ckadmin.domain.AgentUser;
import com.ckerchina.admin.ckadmin.vo.AgentUserVO;

@Repository
public class AgentUserDao extends AbstractDao<AgentUser, Long>{
	public List<AgentUser> findAllAgentUser() {
		return this.entityManager.createQuery("SELECT o FROM AgentUser o ", AgentUser.class)
				.getResultList();
	}
	
	public AgentUser findAgentUserByID(Long id) {
		List<AgentUser> lstUser =  this.entityManager.createQuery("SELECT o FROM AgentUser o WHERE o.id = ?", AgentUser.class).setParameter(1, id)
				.getResultList();
		return lstUser == null ? null : lstUser.get(0);
	}
	
	@SuppressWarnings("unchecked")
	public List<AgentUserVO> findAllAgentUser1() {
		return this.entityManager.createNativeQuery("SELECT id as value,agent_name as display from agent_user", AgentUserVO.class)
				.getResultList();
	}

}
